

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>{$name}</title>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <style type="text/css">
        #panel {
            position: fixed;
            background-color: white;
            max-height: 90%;
            overflow-y: auto;
            top: 10px;
            right: 10px;
            width: 280px;
        }
    </style>
    {include file="public/footer" /}
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.2&key=eef7f290ac06bdf05b246cebc8cb2fb6&plugin=AMap.Walking"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<div id="panel"></div>
<script>
	//获取用户当前地址
var map, geolocation,longitude,latitude;
my_getAddress();
function my_getAddress(){
	var lat="{$lat}";
	var lng="{$lng}";
    //加载地图，调用浏览器定位服务
    var map = new AMap.Map("container", {
        resizeEnable: true,
        center: [lng, lat],//地图中心点
        zoom: 13 //地图显示的缩放级别
    });
    map.plugin('AMap.Geolocation', function() {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,//是否使用高精度定位，默认:true
            timeout: 10000,          //超过10秒后停止定位，默认：无穷大
            buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            buttonPosition:'RB'
        });
        map.addControl(geolocation);
        geolocation.getCurrentPosition();
        AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
    });
    //解析定位结果
    function onComplete(data) {
    	longitude	= data.position.getLng();
		latitude	= data.position.getLat();
		
		//步行导航
	    var walking = new AMap.Walking({
	        map: map,
	        panel: "panel"
	    }); 
	    //根据起终点坐标规划步行路线
	    walking.search([longitude, latitude], [lng, lat]);
    }
}
</script>
</body>
</html>